<?php
namespace Orx\Mailer\MailBox\Message\Background;
/**
 * Message Background Process.
 *
 * It represant a receiver of a message (because then could be multiple)
 *
 * @author Xavier VILAIN
 * @package Hive\Message
 * @property int 		$jobid		Process Unique Id
 * @property int 		$messageid 	Message Unique Id
 * @property int		$type		Type of job
 * @property string	 	$status		Status (9 if failed)
 * @property string	 	$params	 	Params 
 * @property string 	$log		Error Log
 * @property datetime	$cdate		Creation Date
 * @property int		$cname		Author
 * @property datetime	$udate		Last Update Date
 * @property int		$uname		Last Author
 * 
 * @method \Orx\Mailer\MailBox\Message message()
 */
class Job extends \Fox\Object {
	
	/**
	 * Link to Message
	 * @var string
	 */
	const LINK_MESSAGE = 'message';
	
	/**
	 * Move a message to a directory
	 * @var int
	 */
	const TYPE_MOVE_TO = 3;
	
	/**
	 * Delete a message
	 * @var int
	 */
	const TYPE_DELETE = 9;
	
	/**
	 * Mark As Read
	 * @var int
	 */
	const TYPE_MARK_AS_READ = 1;
	
	/**
	 * Mark As Draf
	 * @var int
	 */
	const TYPE_MARK_AS_DRAFT = 5;
		
	/**
	 * Mark As Answered
	 * @var int
	 */
	const TYPE_MARK_AS_ANSWERED = 4;
	
	/**
	 * Status : in error
	 * @var int
	 */
	const STATUS_ERROR = 9;
	
	/**
	 * (non-PHPdoc)
	 * @see Fox.Object::beforeCreate()
	 */
	protected function beforeCreate() {
		$this->udate = $this->cdate = self::sqlDateTime(time()); 
		$this->uname = $this->cname = \User::current()->getId();
		$this->status = 1;
	}
	
}
\Fox\Dao::infos(Job::className(),new \Fox\Object\Info('message_background_jobs', \Fox\Databases::DB_APP));